<template>
  <div>
    <h1>物流管理</h1>
    <el-row>
      <el-button type="danger" round @click="questions">新增物流</el-button>
    </el-row>
    <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="expressId" label="物流编号" width="180"></el-table-column>
      <el-table-column prop="expressModel" label="物流型号" width="180"></el-table-column>
      <el-table-column prop="expressName" label="物流名称" width="180"></el-table-column>
      <el-table-column prop="expressStarttime" label="物流开始派送时间" width="180"></el-table-column>
      <el-table-column prop="expressEndtime" label="物流预计到达时间" width="180"></el-table-column>
      <el-table-column prop="goodsId" label="商品编号" width="180"></el-table-column>
      <el-table-column prop="createTime" label="创建时间" width="180"></el-table-column>
      <el-table-column prop="updateTime" label="最后修改时间" width="180"></el-table-column>
<!--      <el-table-column prop="deleted" label="日期" width="180"></el-table-column>-->
    </el-table>
    <div class="block">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="expersslist.page"
        :page-sizes="[1, 3, 6, 9]"
        :page-size="expersslist.size"
        layout="total, sizes, prev, pager, next, jumper"
        :total="expersslist.total">
      </el-pagination>
    </div>

    <!-- Form -->
    <el-dialog title="添加问题" :visible.sync="dialogFormVisible">
      <el-form :model="eVo">
        <el-form-item label="物流型号" :label-width="formLabelWidth">
          <el-input v-model="eVo.expressModel" autocomplete="off"></el-input>
        </el-form-item>
<!--        <el-form-item label="物流名称" :label-width="formLabelWidth">-->
<!--          <el-input v-model="eVo.expressName" autocomplete="off"></el-input>-->
<!--        </el-form-item>-->



        添加物流名称:<el-input v-model="input" placeholder="请输入内容" style="width: 200px"></el-input>
        <el-button type="success" icon="el-icon-check" circle @click="biaoqian"></el-button>
        <el-form-item label="物流型号" :label-width="formLabelWidth">
            <el-input v-model="expersslist.expressName" placeholder="请输入内容" style="width: 220px"></el-input>
        </el-form-item>
        <br/>
<!--        <el-button type="primary" plain @click="addQuestion">添加</el-button>-->

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="addQuestion">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import axios from "axios";
  export default {
    name: 'Index',
    data(){
      return{
        tableData:[],
        expersslist:{page:1,size:3,total:0,expressName:''},
        eVo:{},
        dialogFormVisible: false,
        formLabelWidth: '120px',
        input:""
      }
    },
    methods:{
      getlist(){
        var us= new FormData();
        us.append("page",this.expersslist.page)
        us.append("size",this.expersslist.size)
        us.append("total",this.expersslist.total)
        axios.post("http://localhost:7000/shop/experss/expersslist",this.expersslist,us).then(res=>{
          console.log(res)
          this.expersslist.total=res.data.data.total
          this.tableData=res.data.data.records
        })
      },
      handleSizeChange(val) {
        this.expersslist.size=val
        console.log(`每页 ${val} 条`);
        this.getlist()
      },
      handleCurrentChange(val) {
        this.expersslist.page=val
        console.log(`当前页: ${val}`);
        this.getlist()
      },
      questions() {
        this.dialogFormVisible = true
      },
      addQuestion() {
        this.dialogFormVisible = false
        axios.post("http://localhost:7000/shop/experss/experssadd",this.eVo).then((res) => {
          this.dialogFormVisible = false
          this.getlist()
          console.log(res)
        })
      },
      biaoqian(){
        this.expersslist.expressName+=this.input+","
      },

    },
    mounted() {
      this.getlist()
    }
  }
</script>

<style scoped></style>
